<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of references_m
 *
 * @author Gidaff_01
 */
class References_m extends CI_Model{
    //put your code here
    function __construct() {
        parent::__construct();
        $this->load->database();
    }

    function get_all_references($per_page, $off_set) {
        $this->db->select();
        $this->db->from('our_references');
        $this->db->limit($per_page, $off_set);
        $query = $this->db->get();
        return $query->result_array();
    }

    function add_references($data) {
        $this->db->insert('our_references', $data);
        return $this->db->affected_rows();
    }

    function get_references_by_id($id) {
        $query = $this->db->get_where('our_references', array('id' => $id));
        return $query;
    }

    function update_references($data, $id) {
        return $this->db->update('our_references', $data, array('id' => $id));
    }

    function delete_references($id) {
        return $this->db->delete('our_references', array('id' => $id));
    }
    function get_top_references(){
        $this->db->select();
        $this->db->from('our_references');
        $this->db->order_by('posted_time','DESC');
        $this->db->limit(6);
        $query = $this->db->get();
        return $query->result_array();
    }

}
?>
